<template>
    <div>
        <div>title</div>

        <!-- form表单 -->
        <form action="">
           <!-- <van-search
        v-model="value"
        placeholder="请输入搜索关键词"
        show-action
        @search="onSearch(value)"
        @cancel="onCancel"
      /> -->
        </form>
        <ul class="infinite-list" v-infinite-scroll="load" style="overflow:auto">
    <li v-for="(item,index) in hotsearch" class="infinite-list-item" :key="index">
        {{index+1}}-- 
        <router-link :to="'/search/'+item.searchWord">
            <div class="searchWord">{{item.searchWord}}</div>
            <div class="content">{{item.content}}</div>
          </router-link>
       
    </li>
  </ul>

    </div>
</template>

<script>
import axios from 'axios'
export default {
    name:'search',
    data(){
        return{
            // 搜索栏
            input:'',
            // 获取默认值
            value:'',
            hotsearch:[]
        }
    },
    methods:{
        // 默认搜索
        getdefault(){
            axios({
                method:'get',
                url:'http://localhost:5000/search/default'
            }).then((res)=>{
                this.value=res.data.data.showKeyword;
            })
        },
        gethotsearch(){
            axios({
                method:'get',
                url:'http://localhost:5000/search/hot/detail'
            }).then((res)=>{
                this.hotsearch=res.data.data;
            })
        },
        // 搜索
        onSearch(keyword){
            this.$router.push({path:"/search/"+keyword})
        },
        // 取消
        onCancel(){
            this.value="";
        }
    },
    mounted(){
        this.gethotsearch();
        this.getdefault();
    }
}
</script>